import 'package:flutter/services.dart';
import 'package:flutter_chubao/config/app_manger_user.dart';
import 'package:flutter_chubao/route/app_route_name.dart';
import 'package:flutter_chubao/tools/app_log.dart';
import 'package:flutter_chubao/widgets/app_alert_dialog.dart';
import 'package:flutter_gromore/callback/gromore_reward_callback.dart';
import 'package:flutter_gromore/callback/gromore_splash_callback.dart';
import 'package:flutter_gromore/config/gromore_reward_config.dart';
import 'package:flutter_gromore/config/gromore_splash_config.dart';
import 'package:flutter_gromore/flutter_gromore.dart';
// import 'package:flutter_gromore_ads/flutter_gromore_ads.dart';
import 'package:get/get.dart';
// import 'package:gromore/gromore.dart';

import 'app_mine_state.dart';

/// @description:
/// @author
/// @date: 2023-12-13 10:17:00
class AppMineLogic extends GetxController {
  final state = AppMineState();
  clickRowsList(String name) async {
    if (AppManagerUser.isLogin()) {
      if (name == '隐私政策') {
        // bool result = await Gromore.register(
        //   //gromore广告 Android appid 必填
        //   androidAppId: "5477562",
        //   //gromore广告 ios appid 必填
        //   iosAppId: "",
        //   //是否debug  上线改为false
        //   debug: true,
        // );
        // FlutterGromore.isInit;
        // bool result = await FlutterGromoreAds.initAd(
        //   '5477562',
        //   // config: AdsConfig.config,
        //   // limitPersonalAds: 1,
        // );
        // DLog("广告SDK 初始化${result ? '成功' : '失败'}");
        Get.toNamed(AppRouteName.appWebPage, arguments: {
          'title': '隐私政策',
          'url': 'https://miniapi.dev.cdzjzx.com/mini/protocol_html?file=yinsi'
        });

        // Get.toNamed(AppRouteName.SsLoanMatchSuccessPage);
        // Get.toNamed(SSRouteNames.SsMineFeedbackPage);
      } else if (name == '注册协议') {
        // await FlutterGromore.showSplashAd(
        //     config: GromoreSplashConfig(
        //         adUnitId: '102696108', logo: "launch_image"),
        //     callback: GromoreSplashCallback(onAdShow: () {
        //       DLog("callback --- onAdShow");
        //     }));

        Get.toNamed(AppRouteName.appWebPage, arguments: {
          'title': '注册协议',
          'url':
              'https://miniapi.dev.cdzjzx.com/mini/protocol_html?file=register'
        });

        // Get.toNamed(SSRouteNames.SsMineSettingPage);
      } else if (name == '关于我们') {
        // loadRewardAd();
        // Get.toNamed(SSRouteNames.SsMineRecordPage);
      } else if (name == '退出登录') {
        Get.dialog(APPAlertDialog(
            infoStr: '确认退出登录吗？',
            actionBtns: (index) {
              DLog(index);
              if (index == 1) {
                AppManagerUser.userLoginOut();
              }
            }));
        // Get.toNamed(SSRouteNames.SsMinePlanPage);
      } else if (name == '注销账号') {
        Get.dialog(APPAlertDialog(
            infoStr: '确认注销账号吗？注销账号之后账号将无法找回',
            actionBtns: (index) {
              DLog(index);
              if (index == 1) {
                AppManagerUser.userLoginOut();
              }
            }));
      }
      //else if (name == '我的账单') {
      //   Get.toNamed(SSRouteNames.SsMineBillPage);
      // } else if (name == '我的额度') {
      //   Get.toNamed(SSRouteNames.SsMineQuotaPage);
      // } else if (name == '帮助中心') {
      //   Get.toNamed(SSRouteNames.SsMineHelpPage);
      // } else if (name == '关于我们') {
      //   Get.toNamed(SSRouteNames.SsMineAboutPage);
      // } else
      if (name == '我的协议') {
        Get.toNamed(AppRouteName.appMineProtocolsPage);
      }
    } else {
      // Get.toNamed(SSRouteNames.SSLoginPage);
    }
  }
}
